<?php echo $this->Html->script('getCategory.js', array('inline' => false)); ?>
<div class="transactions row">
    <div class="col-md-2">
        <h2><kbd><?php echo __('Actions'); ?></kbd></h2>
        <hr/>
        <ul class="nav  nav-stacked ">
            <li><?php echo $this->Html->link(__('New Transaction'), array('action' => 'add')); ?></li>
            <li><?php echo $this->Html->link(__('List Categories'), array('controller' => 'categories', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Category'), array('controller' => 'categories', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('New Wallet'), array('controller' => 'wallets', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('Must Pay'), array('controller' => 'transactions', 'action' => 'listpay')); ?> </li>
            <li><?php echo $this->Html->link(__('Must Revenue'), array('controller' => 'transactions', 'action' => 'listrevenue')); ?> </li>
            <li><?php echo $this->Html->link(__('Set Default Wallet'), array('controller' => 'wallets', 'action' => 'setdefault')); ?> </li>
            <li><?php //echo $this->Html->link(__('New Parent Transaction'), array('controller' => 'transactions', 'action' => 'add'));   ?> </li>
        </ul>
    </div>
    <div class="col-md-10">
        <div class="row">
            <h2><kbd><?php echo __('Wallet'); ?></kbd></h2>
            <hr/>
            <?php foreach ($wallets as $wallet): ?>
                <div class="well">
                    <h4><span class="glyphicon glyphicon-tag"></span>Wallet <?php echo $wallet['Wallet']['id'] ?>:
                        <?php echo $this->Html->link($wallet['Wallet']['name'], array('controller' => 'wallets', 'action' => 'view', $wallet['Wallet']['id'])) ?>
                    </h4>

                    <p><span class="glyphicon glyphicon-usd"></span>Current Money: <span
                            class="text-danger"><?php echo number_format($wallet['Wallet']['current_money']) . ' VNĐ'; ?></span>
                    </p>

                    <p><span class="glyphicon glyphicon-shopping-cart"></span>Spented: <span
                            class="text-danger"><?php echo number_format($wallet['Wallet']['spent']) . ' VNĐ'; ?></span>
                    </p>

                    <p><span class="glyphicon glyphicon-usd"></span>Earned: <span
                            class="text-danger"><?php echo number_format($wallet['Wallet']['earn']) . ' VNĐ'; ?></span>
                    </p>
                </div>
            <?php endforeach; ?>
        </div>
        <div class="row">
            <h2><?php echo __('List Transactions'); ?></h2>
            <hr/>
            <table class="table table-bordered">
                <tr class="success">
                    <th><?php echo $this->Paginator->sort('category_id'); ?></th>
                    <th><?php echo $this->Paginator->sort('wallet_id'); ?></th>
                    <th><?php echo $this->Paginator->sort('transaction_id'); ?></th>
                    <th><?php echo $this->Paginator->sort('money'); ?></th>
                    <th><?php echo $this->Paginator->sort('created'); ?></th>
                    <th><?php echo $this->Paginator->sort('with_who'); ?></th>
                    <th class="actions"><?php echo __('Actions'); ?></th>
                </tr>
            </table>
            <?php echo $this->Form->create('Transaction', array('class' => 'form-horizontal col-md-12 well', 'inputDefaults' => array('label' => false))); ?>
            <div class="form-group col-md-5">
                <h3 class="text-center">View By Date</h3>
                <label class="col-md-4 control-label" for="date">Date: </label>

                <div class="col-md-8">
                    <?php echo $this->Form->input('date', array('class' => 'form-control', 'options' => $dates)); ?>
                </div>
            </div>
            
            <div class="form-group col-md-5">
                <h3 class="text-center">View By Category</h3>

                <div class="form-group">
                    <label class="col-md-5 control-label" for="date">Type: </label>
                    <?php $options = array('1' => 'Spent on', '2' => 'Earned form'); ?>
                    <div class="col-md-7">
                        <?php echo $this->Form->input('type_index', array('class' => 'form-control', 'options' => $options)); ?>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-5 control-label" for="date">Category: </label>

                    <div class="col-md-7">
                        <?php echo $this->Form->input('category', array('class' => 'form-control', 'id' => 'category', 'options' => $category_spent)); ?>
                    </div>
                </div>
            </div>
             <div class="col-md-12 col-md-offset-5  load_ajax">
                <img src ="/moneylover/img/load.gif" class="hidden" id="load"></img>
            </div>
            <?php echo $this->Form->end(); ?>
            <br/><br/>

            <div id="container">
                <?php foreach ($transactions as $transaction): ?>

                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="glyphicon glyphicon-calendar">Date time: <span
                                    class=" text-warning "><?php echo h($transaction['Transaction']['created']); ?></span>
                            </h3>
                        </div>
                        <div class="panel-body">
                            <p>
                            <span
                                class="glyphicon glyphicon-tag"> </span>Wallet: <?php echo $this->Html->link($transaction['Wallet']['name'], array('controller' => 'wallets', 'action' => 'view', $transaction['Wallet']['id'])); ?>
                            </p>

                            <p>
                            <span
                                class="glyphicon glyphicon-tag"> </span>Category:<?php echo $this->Html->link($transaction['Category']['name'], array('controller' => 'categories', 'action' => 'view', $transaction['Category']['id'])); ?>
                            </p>
                            <p>
                            <span
                                class="glyphicon glyphicon-tag"> </span>Type:<span class="text-warning"><?php echo ($transaction['Category']['type'] == 1)?'Earn from':'Spent on';?></span>
                            </p>
                            <p><span
                                    class="glyphicon glyphicon-usd"> </span>Money:<span class="text-danger"><?php echo number_format($transaction['Transaction']['money']) . " VNĐ"; ?></span>
                            </p>

                            <p><span
                                    class="glyphicon glyphicon-user"> </span>With: <?php echo h($transaction['Transaction']['with_who']); ?>
                            </p>
                        </div>

                        <div class="panel-footer">

                            <?php echo $this->Html->link(__('View'), array('action' => 'view', $transaction['Transaction']['id']), array('class' => 'btn btn-sm btn-info glyphicon glyphicon-eye-open')); ?>
                            <?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $transaction['Transaction']['id']), array('class' => 'btn btn-sm btn-warning glyphicon glyphicon-edit')); ?>
                            <?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $transaction['Transaction']['id']), array('class' => 'btn btn-sm btn-danger glyphicon glyphicon-remove'), __('Are you sure you want to delete # %s?', $transaction['Transaction']['id'])); ?>
                        </div>


                    </div>
                <?php endforeach; ?>

                <p class="well-sm">
                    <?php
                    echo $this->Paginator->counter(array(
                        'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
                    ));
                    ?>
                </p>
                <ul class="pagination">
                    <?php
                    echo '<li class="disabled">' . $this->Paginator->prev('< ' . __('previous   '), array(), null, array('class' => 'prev')) . '</li>';
                    echo '<li>' . $this->Paginator->numbers(array('separator' => ' ')) . '</li>';
                    echo '<li class="disabled">' . $this->Paginator->next(__('  next') . ' >', array(), null, array('class' => 'next')) . '</li>';
                    ?>
                </ul>
            </div>

        </div>
    </div>


</div>
